package com.shiyipicture.shiyipicturebackend.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

@Configuration
public class ThreadPoolConfig {

  @Bean
  public ThreadPoolExecutor threadPoolExecutor() {
    // 这里可以根据你的需求调整线程池的参数
    int corePoolSize = 5;
    int maximumPoolSize = 10;
    long keepAliveTime = 60L;
    java.util.concurrent.BlockingQueue<Runnable> workQueue = new java.util.concurrent.LinkedBlockingQueue<>(100);

    return new ThreadPoolExecutor(
      corePoolSize,
      maximumPoolSize,
      keepAliveTime,
      java.util.concurrent.TimeUnit.SECONDS,
      workQueue
    );
  }
}
